import React from "react";
export default (): JSX.Element => {
  console.log(656754);
  const test = () => {
    const downland = function (str: string, time: Date) {
      str += `</tbody>
        </table>`;
      var html =
        "<html><head><meta charset='utf-8' /></head><body>" +
        str +
        "</body></html>";
      var blob = new Blob([html], {
        type: "application/vnd.ms-excel",
      });
      var a = document.createElement("a");
      a.href = URL.createObjectURL(blob);
      a.download = "商品sku统计.xls";
      document.body.appendChild(a);
      a.click();
      document.body.removeChild(a);
      console.log(
        "好了用时",
        (time.getTime() - new Date().getTime()) / 1000,
        "秒"
      );
    };
    fetch("https://web.56xiniao.com/waybillWhole/queryPage", {
      method: "POST",
      headers: {
        "content-type": "application/json;charset=UTF-8",
      },
      body: JSON.stringify({
        waybillNos: null,
        jvCode: "LE08278780",
        receiverPhone: null,
        actualRdcCode: "SC_30408543",
        actualSiteCodes: null,
        customerCodes: null,
        receiverDistrictId: null,
        firstOperateTime: ["2021-11-18 00:00:00", "2021-11-18 23:59:59"],
        collectTime: null,
        signTime: null,
        agentInTime: null,
        statuses: null,
        isIntercept: null,
        isFreight: null,
        isCod: null,
        isDistribution: null,
        pageIndex: 1,
        pageSize: 10,
        collectionPointCode: null,
      }),
    }).then((res) =>
      res.json().then(async (data) => {
        let time = new Date();
        let str = `
          <table border="1">
            <tbody>
              <tr>
                <th>地址</th>
                <th>姓名</th>
                <th>手机</th>
              </tr>
        `;
        let list = data.data.items;
        try {
          for (let i = 0; i < list.length; i++) {
            await new Promise((resolve, reject) => {
              setTimeout(async () => {
                let detail = await (
                  await fetch(
                    `https://web.56xiniao.com/trace/queryReceiverDesensitization?waybillNo=${list[i].waybillNo}&customerCode=ZTO`
                  )
                ).json();
                console.log(
                  detail.data,
                  `第${i + 1}条还剩${list.length - i - 1}`
                );
                str += `
                  <tr>
                    <td>${detail.data?.receiverDetailAddress || "无"}</td>
                    <td>${detail.data?.receiverName || "无"}</td>
                    <td>${detail.data?.receiverPhone || "无"}</td>
                  </tr>
                `;
                resolve(detail);
              }, 2000);
            });
          }
          downland(str, time)
        } catch {
          console.log('出错了，只下载部分')
          downland(str, time)
        }
        // str += `</tbody>
        // </table>`;
        // var html =
        //   "<html><head><meta charset='utf-8' /></head><body>" +
        //   str +
        //   "</body></html>";
        // var blob = new Blob([html], {
        //   type: "application/vnd.ms-excel",
        // });
        // var a = document.createElement("a");
        // a.href = URL.createObjectURL(blob);
        // a.download = "商品sku统计.xls";
        // document.body.appendChild(a);
        // a.click();
        // document.body.removeChild(a);
        // console.log(
        //   "好了用时",
        //   (time.getTime() - new Date().getTime()) / 1000,
        //   "秒"
        // );
      })
    );
  };
  return <div style={{ color: "#fff" }}>404</div>;
};
